import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "about_orm.settings")
import django

django.setup()

from app01 import models
from django.db import transaction

try:
    with transaction.atomic():
        # orm
        book1 = models.Book.objects.get(pk=1)
        book2 = models.Book.objects.get(pk=2)
        book1.num -= 50
        book1.save()
        int('ssss')
        book2.num += 50
        book2.save()

except Exception as e:
    print(e)
